package com.my.mongodbspringdemo.entity;

/**
 * 表单容器。
 */
public class CIFormContainer {
	public static final String TYPE_ATTR = "attribute";
	public static final String TYPE_GROUPLINE = "groupLine";
	private String name;
	private String code;
	private String type;
	private String id;
	private boolean readOnly;
	private boolean oneValueOnly = false; // 针对人员、部门属性，默认可以多选值，也可设置只能填入一个值
	// 布局格式，【单列 | 两列 | 三列】
	private FormLayoutType layoutType = FormLayoutType.SINGLE;

	public CIFormContainer() {
	}

	public static CIFormContainer attributeContainer(String id, String code) {
		return new CIFormContainer(null, TYPE_ATTR, code, null, false, false, FormLayoutType.SINGLE);
	}

	public CIFormContainer(String id, String type, String code, String name, boolean readOnly, boolean oneValueOnly) {
		this(id, type, code, name, readOnly, oneValueOnly, FormLayoutType.SINGLE);
	}

	public CIFormContainer(String id, String type, String code, String name, boolean readOnly, boolean oneValueOnly,
			FormLayoutType layoutType) {
		if (id == null && code != null) {
			this.id = code;
		} else {
			this.id = id;
		}
		this.type = type;
		this.code = code;
		this.name = name;
		this.readOnly = readOnly;
		this.oneValueOnly = oneValueOnly;
		this.layoutType = layoutType;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public boolean isReadOnly() {
		return readOnly;
	}

	public void setReadOnly(boolean readOnly) {
		this.readOnly = readOnly;
	}

	public String toString() {
		return String.format("{\"type\":\"%s\", \"code\":\"%s\", \"name\":\"%s\", \"readOnly\":\"%s\",}", type, code, name, readOnly);
	}

	public FormLayoutType getLayoutType() {
		return layoutType;
	}

	public void setLayoutType(FormLayoutType layoutType) {
		this.layoutType = layoutType;
	}

	public boolean isOneValueOnly() {
		return oneValueOnly;
	}

	public void setOneValueOnly(boolean oneValueOnly) {
		this.oneValueOnly = oneValueOnly;
	}

}
